package cz.muni.fi.pa165.soccergamesarchive.businesslayer.services;

import cz.muni.fi.pa165.soccergamesarchive.businesslayer.dtos.TeamDTO;
import cz.muni.fi.pa165.soccergamesarchive.businesslayer.dtos.TeamDetailDTO;
import java.util.List;
import java.util.Map;
import javax.ejb.Local;

/**
 *
 * @author Martin Fabian
 */
@Local
public interface TeamServiceBeanLocal {

    /**
     * Method addTeam adds team into the database.
     *
     * @param team the team to be added
     *
     * @return
     *
     * @throws IllegalArgumentException if team do not exist or has incorrect
     *                                  record
     */
    public TeamDTO addTeam(TeamDTO team) throws RuntimeException;

    /**
     * Method changeTeam, changes team in database
     *
     * @param team the the team to be changed, instace of team must have set id
     *
     * @return
     *
     * @throws IllegalArgumentException if team do not exist, has not id or has
     *                                  incorrect record
     */
    public TeamDTO changeTeam(TeamDTO team) throws RuntimeException;

    /**
     * Method removeTeam, removes team from database
     *
     * @param team, the team to be removed, instance must have set id
     *
     * @throws IllegalArgumentException if team do not exist or has not id
     */
    public void removeTeam(TeamDTO team) throws RuntimeException;

    /**
     * Method returns List of all teams in database
     *
     * @return list of all teams in database, if no team was found then returns
     *         empty list
     */
    public List<TeamDTO> getAllTeams();

    /**
     * Method getLimitedNumberOfTeams returns list of teams in given interval.
     *
     * @param offset    index of first record
     * @param limit     number of retrieved records
     * @param filterMap
     * @param orderMap
     *
     * @return list of teams in certain interval. Distinct intervals will
     *         contain distinct teams. List will have the size of number of teams in
     *         given interval. If there are no teams in given interval, size of list
     *         will be 0.
     *
     * @throws IllegalArgumentException if from or to has incorrect value
     */
    public List<TeamDTO> getLimitedNumberOfTeams(int offset, int limit,
                                                 Map<String, Object> filterMap,
                                                 Map<String, Boolean> orderMap)
            throws RuntimeException;

    /**
     * Method getTeamById returns team by id
     *
     * @param teamId is ID of team in database
     *
     * @return team that match teamId, null if none was found
     *
     * @throws IllegalArgumentException if teamId has incorrect value
     */
    public TeamDTO getTeamById(Long teamId) throws RuntimeException;

    /**
     * Retrieve team detail from database by specified id
     *
     * @param id id of team to be retrieved
     *
     * @return team detail with specified id or null if team wasnt found
     *
     * @throws IllegalArgumentException if id has incorrect value
     */
    public TeamDetailDTO getTeamDetail(Long id) throws RuntimeException;

    /**
     * Method findTeam finds teams according match in name or managerName
     *
     * @param searchString the query string
     *
     * @return list of found teams
     *
     * @throws IllegalArgumentException if searchString was not specified
     */
    public List<TeamDTO> findTeam(String searchString) throws RuntimeException;

    /**
     * @param team is team of which avaliable shirt numbers wants to know
     *
     * @return free dress numbers, max number is 99
     *
     * @throws IllegalArgumentException if team do not exist, has not id or has
     *                                  incorrect record
     */
    public List<Integer> getAvaliableShirtNumbers(TeamDTO team) throws
            RuntimeException;

    /**
     * Method apply the filter policy to all teams and then return a number of
     * corresponding teams
     *
     * @param filterMap filter policy for current action
     *
     * @return count of teams corresponding to the current filter policy
     *
     * @throws RuntimeException not possible to execute this action
     */
    public int getFilteredTeamsCount(Map<String, Object> filterMap) throws
            RuntimeException;

}
